
 <?php
 // error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);

// Show all information, defaults to INFO_ALL
//phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
 

?>
<h1>系统配置</h1>

 <?php
 $md5 = md5('daoChi12e');
 echo "md5:   " .$md5 ;



$bool = TRUE;   // a boolean
$str  = "foo";  // a string
$int  = 12;     // an integer

echo gettype($bool); // prints out "boolean"
echo gettype($str);  // prints out "string"

// If this is an integer, increment it by four
if (is_int($int)) {
    $int += 4;
}

// If $bool is a string, print it out
// (does not print out anything)
if (is_string($bool)) {
    echo "String: $bool";
}
?>

<!--  http://php.jz123.cn/function.var-dump.html
-->
<pre>
<?php
//error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
$a = array (1, 2, array ("a", "b", "c"));
if  ($a['error']=='timeout') {

  echo  "ffffffffffffffffff";
}
var_dump ($a);


/* 输出：
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  array(3) {
    [0]=>
    string(1) "a"
    [1]=>
    string(1) "b"
    [2]=>
    string(1) "c"
  }
}

*/

$b = 3.1;
$c = TRUE;
var_dump($b,$c);
/* 输出：
float(3.1)
bool(true)

*/
?>
</pre>


例子. 输出控制范例
 <?php

 ob_start();
echo "Hello\n";
setcookie("cookiename", "cookiedata");
//header("location:./hello.php"); //把浏览器重定向到index.php
 ob_end_flush();

?>



usort() 例子  <br/>
<?php
function cmp ($a, $b) {
    if ($a == $b) return 0;
    return ($a < $b) ? -1 : 1;
}

$a = array (3, 2, 5, 6, 1);
usort ($a, "cmp");

while (list ($key, $value) = each ($a)) {
    echo "$key: $value\n";
}



 //  explode() 函数 :把字符串打散为数组：
$str = "Hello world. I love Shanghai!";
print_r (explode(" ",$str));
  $packinfo=explode(" ",$str);
      $package_code=$packinfo[1];
      $phone_num_key=$packinfo[2];

print_r ($packinfo);
date_default_timezone_set("Asia/Shanghai");
list($usec, $sec) = explode(" ", microtime());
echo "microtime: ".microtime()."list:";
echo   $usec.'sec:'.$sec."\n";
  $date = date ( 'YmdHis', time () );
  echo   'sec123:'.$date."\n";

 $date2 = sprintf ( "%03d", $usec * 1000 );
    echo   'sec123:'.$date2."\n";

?>

<?php
$nextWeek = time( )  ;  //1970到现在的秒
 echo 'time is: '.  $nextWeek  ."\n";
 echo 'time is: '. date('Y-m-d h:i:sa', '1450326709') ."\n";
echo date ( 'Ymd',  '1450326709' );
?>

 <h1> 字符串  ：</h1>

<?php
$number = 123;
$number2=235;
$txt = sprintf("带两位小数：%1\$.2f
<br>不带小数：%2\$u",$number,$number2);
echo $txt;
?>

 <?php
echo 'this is a simple string';

echo 'You can also have embedded newlines in
strings this way as it is
okay to do';

// Outputs: Arnold once said: "I'll be back"
echo 'Arnold once said: "I\'ll be back"';

// Outputs: You deleted C:\*.*?
echo 'You deleted C:\\*.*?';

// Outputs: You deleted C:\*.*?
echo 'You deleted C:\*.*?';

// Outputs: This will not expand: \n a newline
echo 'This will not expand: \n a newline';

// Outputs: Variables do not $expand $either
echo 'Variables do not $expand $either';
?>

<h3>字符串函数</h3>
<h4>1,strpos() examples</h4>
<?php
$mystring = 'abc\\';
$findme   = '\\';
$pos = strpos($mystring, $findme);
// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos !== false) {
    echo "The string '$findme' was not found in the string '$mystring'";
} else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos <br/>";
}
$mystring = '运营商系统繁忙，请稍候重试';
$findme   = '。';
$pos = strpos($mystring, $findme);
 $substr=   substr($mystring,0,$pos);
 echo "strpos  :[" . __FILE__ . "] line:[" . __LINE__ . "]     substr:" .$pos. $substr . "<br/>\r\n";


// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 2); // $pos = 7, not 0
if ($pos === false) {
    echo "The string '$pos' was not found in the string '$newstring'</br>";
} else {
    echo "The string '$pos' was found in the string '$newstring'";
    echo " and exists at position $pos";
}

?>

<h4>2,strstr() example</h4>
<?php
$email = 'user@example.com';
//true  截取之前的，  false : 截取之后的
$domain = strstr($email, '@',true);
echo $domain; // prints @example.com
?>




<h3>字符串转换为数值:  http://php.jz123.cn/language.types.string.html#language.types.string.conversion </h3>
 <?php
$foo = 1 + "10.5";                // $foo is float (11.5)
$foo = 1 + "-1.3e3";              // $foo is float (-1299)

echo "\$foo==$foo; type is " . gettype ($foo) . "<br />\n";

$foo = 1 + "bob-1.3e3";           // $foo is integer (1)
$foo = 1 + "bob3";                // $foo is integer (1)
$foo = 1 + "10 Small Pigs";       // $foo is integer (11)
echo "\$foo==$foo; type is " . gettype ($foo) . "<br />\n";

$foo = 4 + "10.2 Little Piggies"; // $foo is float (14.2)
$foo = "10.0 pigs " + 1;          // $foo is float (11)
echo "\$foo==$foo; type is " . gettype ($foo) . "<br />\n";

$foo = "fff124410.0 pigs " + "ffff2.0";        // $foo is float (11)
echo "\$foo==$foo; type is " . gettype ($foo) . "<br />\n";

?>

<h3 >定界符字符串例子   </h3>
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
    var $foo;
    var $bar;

    function foo()
    {
        $this->foo = 'Foo';
        $this->bar = array('Bar1', 'Bar2', 'Bar3');
    }
}

$foo = new foo();
$name = 'MyName';

echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
?>

 <?php
$beer = 'Heineken';
echo "$beer's taste is great"; // works, "'" is an invalid character for varnames
echo "He drank some $beers";   // won't work, 's' is a valid character for varnames
echo "He drank some ${beer}s"; // works
echo "He drank some {$beer}s"; // works
?>


 <?php
// These examples are specific to using arrays inside of strings.
// When outside of a string, always quote your array string keys
// and do not use {braces} when outside of strings either.

// Let's show all errors


$fruits = array('strawberry' => 'red', 'banana' => 'yellow');
print_r("hhhh".$fruits."123");
// Works but note that this works differently outside string-quotes
echo "<br/>1 A banana is $fruits[banana].haha";
// Works
echo "2 A banana is {$fruits['banana']}.";

 // Works but PHP looks for a constant named banana first
// as described below.
echo "3 A banana is {$fruits[banana]}.";

// Won't work, use braces.  This results in a parse error.
 //echo "A banana is $fruits['banana'].";

// Works
echo "4 A banana is  jing  " . $fruits['banana'] . ".";

?>

 <h3>复杂（花括号）语法 </h3>
 <?php
// Let's show all errors


$great = 'fantastic';

// 不行，输出为：This is { fantastic}
echo "1 This is { $great}";

// 可以，输出为：This is fantastic
echo "2 This is {$great}";
echo "3 This is ${great}";


?>


<br/> 字符串运算符 http://php.jz123.cn/language.operators.string.html  <br/>
<?php

$a = "Hello ";
$b = $a . "World!"; // now $b contains "Hello World!"
echo "${b}  ";
$a = "Hello ";
$a .= "World!";     // now $a contains "Hello World!"
 echo "$a  ";

  ?>

<h1>ARRay  数组 </h1>
<h4>foreach  http://php.jz123.cn/control-structures.foreach.html
数组函数库  http://php.jz123.cn/ref.array.html</h4>

   <?php
$arr = array(5 => 1, 12 => 2);
echo "\$arr==" . print_r($arr) . " type is " . gettype ($arr) . "<br />\n";

$arr[] = 56;    // This is the same as $arr[13] = 56;
                // at this point of the script
echo "\$arr==" . print_r($arr) . " type is " . gettype ($arr) . "<br />\n";

$arr["x"] = 42; // This adds a new element to
                // the array with key "x"
echo "\$arr==" . print_r($arr) . " type is " . gettype ($arr) . "<br />\n";

unset($arr[5]); // This removes the element from the array
//echo "\$arr==" . print_r($arr) . " type is " . gettype ($arr) . "<br />\n";

unset($arr);    // This deletes the whole array
//echo "\$arr==" . print_r($arr) . " type is " . gettype ($arr) . "<br />\n";

?>
 <?php
// 创建一个简单的数组
$array = array(1, 2, 3, 4, 5);
print_r($array );
echo "<br />\n";
// 现在删除其中的所有单元，但保持数组本身的结构
foreach ($array as $i => $value) {
    unset($array[$i] );
}
print_r($array );
echo "<br />\n";
// 添加一个单元（注意新的键名是 5，而不是你可能以为的 0）
$array[] = 6;
print_r($array );
echo "<br />\n";
// 重新索引：
$array = array_values($array);
$array[] = 7;
print_r($array );
?>


 list() 例子
<?php
 echo " <br />\n LINE:".__LINE__.":";

$info = array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
print "$drink is $color and $power makes it special.\n\t";

// Listing some of them
list($drink, , $power) = $info;
print "$drink has $power.\n";

// Or let's skip to only the third one
list( , , $power) = $info;
print "I need $power!\n";

?>
<br/>

<?php
 echo " <br />\n LINE:".__LINE__.":";


$a=array("a"=>"Dog","b"=>"Cat");
array_push($a,"Horse","Bird");
print_r($a);
?>
<br/>
<?php
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
echo array_shift($a);
print_r ($a);
?>
<h1>  对象 </h1>
 <?php
class foo1
{
    function do_foo()
    {
        echo "Doing foo.";
    }
}

$bar = new foo1;
$bar->do_foo();
?>
<h1> 资源 </h1>
<h4> http://php.jz123.cn/resource.html</h4>


<h1>变量</h1>
<h3>基础</h3>
 <?php
$foo = 'Bob';              // Assign the value 'Bob' to $foo
$bar = &$foo;              // Reference $foo via $bar.
$bar = "My name is $bar";  // Alter $bar...
echo $bar;
echo $foo;                 // $foo is altered too.
?>

<h3>预定义变量</h3>
<p> PHP 4.2.0 以及后续版本中，PHP 指令 register_globals 的默认值为 off。这是 PHP 的一个主要变化。让 register_globals 的值为 off 将影响到预定义变量集在全局范围内的有效性。例如，为了得到 DOCUMENT_ROOT 的值，你将必须使用 $_SERVER['DOCUMENT_ROOT'] 代替 $DOCUMENT_ROOT，又如，使用 $_GET['id'] 来代替 $id 从 URL http://www.example.com/test.php?id=3 中获取 id 值，亦或使用 $_ENV['HOME'] 来代替 $HOME 获取环境变量 HOME 的值。 </p>
<p>register_globals  在php.ini </p>

 下面的配合 test.html  演示
 <!--<?php echo $_SERVER["HTTP_USER_AGENT"]; ?>

 Hi <?php echo $_POST["name"]; ?>.
 You are <?php echo $_POST["age"]; ?> years old.
 -->

 <h4>服务器变量  $_SERVER</h4>
<?php
 echo  $_SERVER["GATEWAY_INTERFACE"] ;
 //  当前执行脚本的绝对路径名<br/>
 echo  $_SERVER["SCRIPT_FILENAME"];
  print_r( $_ENV ) ;

?>


 <?php

/* set the session name to WebsiteID */

$previous_name = session_name("WebsiteID");

echo "The previous session name was $previous_name<p>";
?>
<h4>系统定义常量(magic constant)</h4>
<?php

$dir =dirname(__FILE__);


print_r( $dir);
print_r( __FILE__);
print_r( __DIR__);

?>




<h3>变量范围</h3>
 <?php
$a = 1;
$b = 2;

function Sum()
{
    global $a, $b;

    $b = $a + $b;
}

Sum();
echo $b;
?>

 <?php
$a = 1;
$b = 2;

function Sum2()
{
    $GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
}

Sum2();
echo $b;
?>



 <?php
function test_global()
{
    // 大多数的预定义变量并不 "super"，它们需要用 'global' 关键字来使它们在函数的本地区域中有效。
    global $HTTP_POST_VARS;

    print $HTTP_POST_VARS['name']="jing";
 //$HTTP_POST_VARS['name']="jing";
    // Superglobals 在任何范围内都有效，它们并不需要 'global' 声明。Superglobals 是在 PHP 4.1.0 引入的。
    print $_POST['name'];
}

test_global();

    print $HTTP_POST_VARS['name'];

?>

<h4>使用静态变量的例子</h4>
 <?php
function Test()
{
    static $a = 0;
    echo $a;
    $a++;
}
Test();
Test();
?>


 <?php
 //没怎么看明白
function &get_instance_ref() {
    static $obj;
    echo "Static object: ";
    var_dump($obj);
    if (!isset($obj)) {
        // 将一个引用赋值给静态变量
        $obj = &new stdclass;
    }
    $obj->property++;
    return $obj;
}

function &get_instance_noref() {
    static $obj;

    echo "Static object: ";
    var_dump($obj);
    if (!isset($obj)) {
        // 将一个对象赋值给静态变量
        $obj = new stdclass;
    }
    $obj->property++;
    return $obj;
}

$obj1 = get_instance_ref();
$still_obj1 = get_instance_ref();
echo "\n";
$obj2 = get_instance_noref();
$still_obj2 = get_instance_noref();
?>

<h3>PHP 的外部变量</h3>

结合test.html 第二个提交
<?php
// 自 PHP 4.1.0 起可用

   print $_POST['username']."1";
   print $_REQUEST['username']."2";

  // import_request_variables('p', 'p_');
  // print $p_username."3";

// 自 PHP 3 起可用。自 PHP 5.0.0 起，这些较长的预定义变量
// 可用 register_long_arrays 指令关闭。

   print $HTTP_POST_VARS['username']."4";

// 如果 PHP 指令 register_globals = on 时可用。不过自
// PHP 4.2.0 起默认值为 register_globals = off。
// 不提倡使用/依赖此种方法。

   print $username;
?>


 <?php
if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
    print '<pre>';

    print_r($_POST);
    print '<a href="'. $_SERVER['PHP_SELF'] .'">Please try again</a>';

    print '</pre>';
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
    Name:  <input type="text" name="personal[name]"><br>
    Email: <input type="text" name="personal[email]"><br>
    Beer: <br>
    <select multiple name="beer[]">
        <option value="warthog">Warthog</option>
        <option value="guinness">Guinness</option>
        <option value="stuttgarter">Stuttgarter Schwabenbr漉</option>
    </select><br>
    <input type="hidden" name="action" value="submitted">
    <input type="submit" name="submit" value="submit me!">
</form>
<?php
}
?>

<h3>常量</h3>

 <?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.
?>


<h1>运算符</h1>

 <?php
$output = `ls -al`;
echo "<pre>$output</pre>";
?>
22222
 <?php
echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.

$last_line = system('ls', $retval);

// Printing additional info
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
?>


33333
 <?php
$e = escapeshellcmd($userinput);

// here we don't care if $e has spaces
system("echo $e");
$f = escapeshellcmd($filename);

// and here we do, so we use quotes
system("touch \"/tmp/$f\"; ls -l \"/tmp/$f\"");
?>

<h3>错误控制运算符</h3>
 <?php
/* Intentional file error */
//$my_file = @file ('non_existent_file') or
//    die ("Failed opening file: error was '$php_errormsg'");

// this works for any expression, not just functions:
$value = @$cache[$key];
// will not issue a notice if the index $key doesn't exist.

?>

<h1>流程控制</h1>
 <?php
if ($a == 5):
    print "a equals 5";
    print "...";
elseif ($a == 6):
    print "a equals 6";
    print "!!!";
else:
    print "a is neither 5 nor 6";
endif;
?>

<h1>函数</h1>

<h4>向函数传递数组</h4>
<?php
function takes_array($input)
{
    echo "$input[0] + $input[1] = ", $input[0]+$input[1];
}
?>
<h4>通过引用传递参数</h4>
 <?php
function add_some_extra(&$string)
{
    $string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str;    // outputs 'This is a string, and something extra.'
?>

<h4>函数中默认参数的用途</h4>
<?php
function makecoffee ($type = "cappuccino")
{
    return "Making a cup of $type.\n";
}
echo makecoffee ();
echo makecoffee ("espresso");
?>


<h3>内部（内建）函数</h3>
<h5>md5()</h5>
<?php
$str = "Shanghai";
echo md5($str);

if (md5($str) == "5466ee572bcbc75830d044e66ab429bc")
  {
  echo "<br>Hello world!";
  //exit;
  }
?>
<?php
$errorMsginput='手机号码在中国电信还有未完成的工单，请解决后再试';
 echo "switch  :[" . __FILE__ . "] line:[" . __LINE__ . "]     errorMsginput:" . $errorMsginput . "<br/>\r\n";

if ( $errorMsginput) {
    switch ($errorMsginput) {

      case "流量充值未成功" :
        $errorMsg = "unsuccessed";
        break;
      case "手机号码在中国电信还有未完成的工单，请解决后再试" :
        $errorMsg = "suspended";
        break;
      default :
        $errorMsg = "arr ['errorMsg']";
    }
  }

    if (strpos ( $errorMsginput, "ff" ))
      $errorMsg = "unfinishedoper";

 echo "switch  :[" . __FILE__ . "] line:[" . __LINE__ . "]     errorMsg:" . $errorMsg . "<br/>\r\n";

?>




<h3>网络相关</h3>
<h4>1,CURL  Client URL Library Functions</h4>
<?php
// 初始化一个 cURL 对象
$curl = curl_init();
// 设置你需要抓取的URL
curl_setopt($curl, CURLOPT_URL, 'http://www.haosou.com');
// 设置header
curl_setopt($curl, CURLOPT_HEADER, 1);
// 设置cURL 参数，要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// 运行cURL，请求网页
//$data = curl_exec($curl);
// 关闭URL请求
//curl_close($curl);
// 显示获得的数据
//var_dump($data);

 ?>
<h5>urlencode& urldecode(还原 URL 编码字符串)</h5>
<?php
$EncodeStr=urlencode("http://www.haosou.com");
echo $EncodeStr  ;
$EncodeStr=urldecode($EncodeStr);
echo $EncodeStr  ;
?>
<h5>rtrim(从字符串右侧移除字符)</h5>

<?php
 $serverUrl = "http://ecs.aliyuncs.com/";
 $requestUrl = rtrim($serverUrl,"/") . "/?";
echo $requestUrl. "<br>";
?>


<h4>join 功能等同于 implode</h4>
 <?php

$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);

echo $comma_separated; // lastname,email,phone

?>


<h4>file_put_contents</h4>

<?php
$contents = "这是使用file_put_contents写入的内容";
$contents2 = array("这是使用","file_put_contents","命令写入的内容");
file_put_contents("cache.txt",$contents);
file_put_contents("cache2.txt",$contents2);
?>

<h3>URL 函数库  使用 MIME base64 对数据进行编码</h3>
<h4>base_64encode</h4>
 <?php
  $str = 'This is an encoded string';
  echo base64_encode($str);
?>

<h3>mysql</h3>

<?php
error_reporting(E_ALL ^ E_DEPRECATED);

$db_host   = "localhost:3308";
// database name
$db_name   = "mysql";
// database username
$db_user   = "root";
// database password
$db_pass   = "jinga";
$sqlstr ="select * from user ";
echo   do_query( $sqlstr );
function do_query($str)
{
    $connection=mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'],$GLOBALS['db_pass']) or die("Unable to connect!");
    mysql_query("set names 'utf8'");//这就是指定数据库字符集，一般放在连接数据库后面就系了
    mysql_select_db($GLOBALS['db_name']) or die("Unable to select database!");
    $rs = mysql_query($str) or die("Error in query. ".mysql_error());

while($row = mysql_fetch_row($rs))
echo " $row[1] $row[2] $row[3] ";   //显示数据

    return $rs;
}

?>

<h3>日期  date</h3>
<?php
$t=time();
echo($t . "<br />");
echo(date("D F d Y",$t));


$date=date('Y-m-d h:i:sa',time());
//$date.= sprintf("%03d", $usec*1000);
echo "date:".$date."<br/>\r\n" ;
  $date=date('YmdHis',time());
  echo "date:".$date."<br/>\r\n" ;
?>



<h1>类与对象</h1>
  serialize()  unserialize()
 session_register()

<h4>php面向对象编程之构造方法__construct() </h4>
<?php
    class Person{

            public $name;
            public $age;
            public $sex;

        public function __construct($name="",$sex="男",$age=27){      //显示声明一个构造方法且带参数
            $this->name=$name;
            $this->sex=$sex;
                        $this->age=$age;
        }
        public function say(){
            echo "我叫：".$this->name."，性别：".$this->sex."，年龄：".$this->age;
        }

    }

?>

<?php
//创建对象$Person1且不带任参数
$Person1= new Person();
echo $Person1->say();//输出:我叫：，性别：男，年龄：27
//创建对象$Person2且带参数"张三"
$Person2= new Person("张三");
    echo $Person2->say();//输出：我叫：张三，性别：男，年龄：27
//创建对象$Person3且带三个参数
    $Person3= new Person("李四","男",25);
    echo $Person3->say();//输出：我叫：李四，性别：男，年龄：25
?>

<?php
class A {
public $name; //名字
function __construct($name){ //构造函数
$this->name = $name;
}

function test(){
echo $this->name;
}

function  recall(){

  echo "class a" ;
}
}

//派生类
class B extends A{
function __construct(){
parent::__construct("测试2"); //调用或者说继承父类的构造函数:
self::test();


}

function  recall(){

  echo "class b" ;
}
}
$b = new B();

$b->recall();  //调用子类的
 ?>

<h4>转换为对象</h4>

<?php
$obj = (object) 'ciao';
echo $obj->scalar;  // outputs 'ciao'
?>

<h4>json_decode() 的例子</h4>
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

var_dump(json_decode($json));
var_dump(json_decode($json, true));  //当该参数为 TRUE 时，将返回 array 而非 object 。
 $test1 =json_decode($json);
$test2 =json_decode($json,true );
echo "b:".$test1->{'b'}."<br/>";
echo  $test2['b']."<br/>";
var_dump(json_encode($test1));

var_dump(json_encode($test2));


$request = array ();
      list ( $usec, $sec ) = explode ( " ", microtime () );
      $date = date ( 'YmdHis', time () );
      $date .= sprintf ( "%03d", $usec * 1000 );
      $request ['appId'] = 123;
      $request ['productId'] =1234;
      $request ['mobile'] = 18591771963;
      $request ['effect'] = "0";
  $reqstr = json_encode ( $request );
 echo "reqstr:".$reqstr."<br/>";


 $json =   '{"alibaba_aliqin_flow_wallet_charge_response":{"charge":"{error=false, errorCode=null, value=true, class=com.alicom.flow.domain.TopResultDO, errorMsg=null}","request_id":"qm38gy1m2573"}}'  ;

 $test3=  json_decode($json,true) ;

echo "1"."<br/>";

 print_r($test3 );
echo "+++2"."<br/>";

   echo $test3['alibaba_aliqin_flow_wallet_charge_response']['charge']."<br/>";
   $charge=$test3['alibaba_aliqin_flow_wallet_charge_response']['charge'];

    $charge=explode(',',substr($charge,1,-1) );
    echo "+++3"."<br/>";
    print_r($charge);
    echo "+++4"."<br/>";
     print_r( explode('=',$charge[3] )[1] );

   $json2 =   '{"messages":{"tmc_message": {"content": {"phone":13366887131,"status":"3","channelId":"0000025_DCZH_9EE34D4E69A0BAAF","outId":"20150909145350000","errorMsg":"","dataid":186422345},"id":"4.2115008413161E+18", "pub_app_key":"12497914", "pub_time":"2015-09-09 20:58:35", "topic":"alibaba_aliqin_FlowDirectCharge","user_id":"2434960004", "user_nick":"道驰纵横"   } },"request_id":"16ceujmw5qakt"} '  ;

 // stdClass Object ( [messages] => stdClass Object ( [tmc_message] => stdClass Object ( [content] => stdClass Object ( [phone] => 13366887131 [status] => 3 [channelId] => 0000025_DCZH_9EE34D4E69A0BAAF [outId] => 20150909145350000 [errorMsg] => [dataid] => 186422345 ) [id] => 4.2115008413161E+18 [pub_app_key] => 12497914 [pub_time] => 2015-09-09 20:58:35 [topic] => alibaba_aliqin_FlowDirectCharge [user_id] => 2434960004 [user_nick] => 道驰纵横 ) ) [request_id] => 16ceujmw5qakt )



echo "+++5"."<br/>";
print_r( json_decode($json2 ));
 var_dump(json_decode($json2 ));
 $test4=  json_decode($json2,true ) ;
     print_r($test4['messages']['tmc_message']);


// $str = "Hello Friend";

// $arr1 = str_split($str);
// $arr2 = str_split($str, 3);

// print_r($arr1);
// echo "<br/>";
// print_r($arr2);


?>

<h2> 插件  扩展功能</h2>

<h3 style="color:red">redis</h3>
<h5>测试1 /h5>


<h5>测试4 </h5>
<?php

 ?>
</body>
</html>

